<?php
#============================
#	Filename: msglist_one.qgmod.php
#	Note	: Note
#	Version : 2.0
#	Author  : ovsexia
#	Update  : 2017-08-31
#============================
global $FS,$DB,$PA,$prefix,$bi;
$md5 = md5(TemplateID."_".$id."_".$words);
$cache_file = "data/cache/list_".$md5.".php";#[缓存文件]
$check_status = false;
if($iscache)
{
	$check_status = CheckCache($cache_file);#[判断缓存文件的存储状态]
}
if($check_status)
{
	include_once($cache_file);
	unset($cache_file);
	return $list;
}
#[取得信息]
$sql = "SELECT m.*,u.filename AS u_filename,u.thumbfile AS u_thumbfile,u.markfile AS u_markfile,u.folder AS u_folder FROM ".$prefix."msg AS m LEFT JOIN ".$prefix."upfiles AS u ON m.thumb=u.id WHERE m.id IN(".$id.") AND m.ifcheck='1' ORDER BY field(m.id,".$id.")";
$list = $DB->qgGetAll($sql);
if(!$list)
{
	unset($cache_file);
	return false;
}
$i = 1;
foreach($list AS $key=>$value)
{
	$value["subject"] = $value["subject".$bi];
	
	$sql = "SELECT * FROM ".$prefix."msg_content WHERE id='".$value["id"]."' ";
	$rsc = $DB->qgGetOne($sql);
	/*清除标签*/
	$value["content"] = $rsc["content".$bi];
	$value["cut_content"] = strip_tags($value["content"]);
	$value["cut_content"] = CutString(str_replace(array("<p>","</p>","<div>","</div>","<br />","&nbsp;","　"),array("","","","","","",""),$value["cut_content"]),$words);
	
	$value["folder"] = $value["u_folder"];
	$value["filename"] = $value["u_filename"];
	$value["markfile"] = $value["u_markfile"];
	$value["thumbfile"] = $value["u_thumbfile"];

	//裁剪图片
	$sysimg = $PA->sysize($value["cateid"]);
	$swidth = $sysimg["width"];
	$sheight = $sysimg["height"];
	$value["cutimg"] = "images.php?imgurl=".base64_encode($value["folder"].$value["filename"])."&swidth=".$swidth."&sheight=".$sheight;
	unset($value["u_folder"],$value["u_filename"],$value["u_markfile"],$value["u_thumbfile"]);
	
	$sql = "SELECT catename,catename_en,catename_ft FROM ".$prefix."category WHERE id='".$value["cateid"]."' ";
	$rsc = $DB->qgGetOne($sql);
	$value["catename"] = $rsc["catename".$bi];
	$value["catename_en"] = $rsc["catename_en"];
	
	#[获取自定义字段]
	$value["fieldlist"] = $PA->fieldlist($value["id"]);
	if($value["fieldlist"])
	{
		foreach($value["fieldlist"] AS $key2=>$value2)
		{
			$value[$value2["sign"]] = $value2["field_content"];
		}
	}
	
	#[日期转换]
	$value["year"] = date("Y",$value["postdate"]);
	$value["day"] = date("d",$value["postdate"]);
	$value["month"] = monthc(date("m",$value["postdate"]),"min"); //[min] or [ful]

	//首项尾项
	if($i==1)
	{
		$value["first"] = true;
	}
	if($i==count($list))
	{
		$value["last"] = true;
	}
	$value["row_index"] = $i;
	$rslist[] = $value;
	$i++;
}

$msglist = _____QGMODULE_CLEARUP_LIST($rslist,$words,true);
$list["list"] = $msglist;

$FS->qgWrite($list,$cache_file,"list");
unset($rslist,$msglist,$cache_file);
return $list;
?>